package threaddemo13;

/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2022-08-06
 * Time: 23:46
 */
//演示死锁
    //线程死锁是指由于两个或者多个线程互相持有对方所需要的资源，导致这些线程处于等待状态，无法前往执行
public class TestDemo {
    public static void main(String[] args) {
        Object o1=new Object();
        Object o2=new Object();
        
        //演示lambada创建线程
        new Thread(()->{
            while (true){
                synchronized (o1){
                    synchronized (o2){
                        System.out.println("小刘在走路");
                    }
                }
            }
        }).start();
        
        new Thread(()->{
            while (true){
                synchronized (o2){
                    synchronized (o1){
                        System.out.println("小邓在走路");
                    }
                }
            }
        }).start();
    }
}
